#ifndef EMULATOR_INTERFACE_H_
#define EMULATOR_INTERFACE_H_

#include "uarch/types.h"
#include "uarch/module.h"

using namespace std;

class processor;
class Thread;
class ThreadContext; /** SESC specific.  */

class Emulator_interface
{
public:
    Emulator_interface ();
    ~Emulator_interface ();

    void schedule ();

    /** Processor map - A map of lists.
        The map index ranges between 0 and the number of threads 
        per processor.  Each list contains processors that have
        the same number of active contexts.  This scheme is used 
        to allocate processors with the fewest active threads first.
    */
    MAP<int, LIST<processor*> > processor_map;
    bool free_processor_p ();
    processor *get_next_processor ();
    void update_processor_map (processor *pr);

    /** Ready and stalled threads.  */
    LIST<Thread*> thread_ready_list;
    LIST<Thread*> thread_stalled_list;
    LIST<Thread*> thread_exited_list;
    MAP<int, Thread*> thread_map;

    /** Trace.  */
    void init_trace ();
    void init_emul ();

    /** SESC System calls.  */
    void sysClone (ThreadContext *context);

    /** ThreadContext suspend/resume/exit.  */
    void thread_suspend (int tid);
    void thread_resume (int tid);
    void thread_exit (int tid);
};

#endif /* EMULATOR_INTERFACE_H_ */
